import axios from "axios";
import { message } from "antd";
const proRequest = axios.create({
    baseURL:'http://gmall-h5-api.atguigu.cn',
    timeout:5000,
})
// 请求拦截
// proRequest.interceptors.request.use((config:any)=>{
//     if(localStorage.getItem("token"))
//         config.headers.token = localStorage.getItem("token");
//     return config;
// });
// 响应拦截
proRequest.interceptors.response.use(result=>{
    const body = result.data;
    if(body.code === 200)  return body;
    else {
        message.error(body.message);
        return Promise.reject(body.message);// 生成一个失败的promise
    }
   
})


export default proRequest;

